package com.restaurant.application.indexes.consumptionlist.support;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;

import java.util.List;

public class BandBean implements PickableBean {

    public static final String FN_SHOPID = "shopId";
    public static final String FN_NUMBER = "number";
    public static final String FN_TIME = "time";
    public static final String FN_DESKNUMBER = "deskNumber";
    public static final String FN_TOTALPRICE = "totalPrice";
    public static final String FN_FINALPRICE = "finalPrice";
    public static final String FN_ENSUREPRICE = "ensurePrice";
    public static final String FN_CUSTOMERID = "customerId";
    public static final String FN_PHONE = "phone";

    public static final List<String> FIELD_NAMES = Lists.newArrayList(
            FN_SHOPID,
            FN_NUMBER,
            FN_TIME,
            FN_DESKNUMBER,
            FN_TOTALPRICE,
            FN_FINALPRICE,
            FN_ENSUREPRICE,
            FN_CUSTOMERID,
            FN_PHONE);

    private String shopId;
    private String number;
    private Long time;
    private Long deskNumber;
    private Double totalPrice;
    private Double finalPrice;
    private Double ensurePrice;
    private String customerId;
    private String phone;

    public BandBean(String shopId, String number, Long time, Long deskNumber, Double totalPrice, Double finalPrice, Double ensurePrice, String customerId, String phone) {
        setShopId(shopId);
        setNumber(number);
        setTime(time);
        setDeskNumber(deskNumber);
        setTotalPrice(totalPrice);
        setFinalPrice(finalPrice);
        setEnsurePrice(ensurePrice);
        setCustomerId(customerId);
        setPhone(phone);
    }

    public BandBean() {
    }

    public BandBean duplicate() {
        BandBean result = new BandBean();
        result.shopId = this.shopId;
        result.number = this.number;
        result.time = this.time;
        result.deskNumber = this.deskNumber;
        result.totalPrice = this.totalPrice;
        result.finalPrice = this.finalPrice;
        result.ensurePrice = this.ensurePrice;
        result.customerId = this.customerId;
        result.phone = this.phone;
        return result;
    }

    @Override
    public String toString() {
        return Convert.toJson(this);
    }

    public String getShopId() {
        return shopId;
    }

    public void setShopId(String value) {
        this.shopId = value;
    }

    public BandBean withShopId(String value) {
        setShopId(value);
        return this;
    }

    public BandBean withShopId(String value, String defaultValue) {
        setShopId(value == null ? defaultValue : value);
        return this;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String value) {
        this.number = value;
    }

    public BandBean withNumber(String value) {
        setNumber(value);
        return this;
    }

    public BandBean withNumber(String value, String defaultValue) {
        setNumber(value == null ? defaultValue : value);
        return this;
    }

    public Long getTime() {
        return time;
    }

    public void setTime(Long value) {
        this.time = value;
    }

    public BandBean withTime(Long value) {
        setTime(value);
        return this;
    }

    public BandBean withTime(Long value, Long defaultValue) {
        setTime(value == null ? defaultValue : value);
        return this;
    }

    public Long getDeskNumber() {
        return deskNumber;
    }

    public void setDeskNumber(Long value) {
        this.deskNumber = value;
    }

    public BandBean withDeskNumber(Long value) {
        setDeskNumber(value);
        return this;
    }

    public BandBean withDeskNumber(Long value, Long defaultValue) {
        setDeskNumber(value == null ? defaultValue : value);
        return this;
    }

    public Double getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(Double value) {
        this.totalPrice = value;
    }

    public BandBean withTotalPrice(Double value) {
        setTotalPrice(value);
        return this;
    }

    public BandBean withTotalPrice(Double value, Double defaultValue) {
        setTotalPrice(value == null ? defaultValue : value);
        return this;
    }

    public Double getFinalPrice() {
        return finalPrice;
    }

    public void setFinalPrice(Double value) {
        this.finalPrice = value;
    }

    public BandBean withFinalPrice(Double value) {
        setFinalPrice(value);
        return this;
    }

    public BandBean withFinalPrice(Double value, Double defaultValue) {
        setFinalPrice(value == null ? defaultValue : value);
        return this;
    }

    public Double getEnsurePrice() {
        return ensurePrice;
    }

    public void setEnsurePrice(Double value) {
        this.ensurePrice = value;
    }

    public BandBean withEnsurePrice(Double value) {
        setEnsurePrice(value);
        return this;
    }

    public BandBean withEnsurePrice(Double value, Double defaultValue) {
        setEnsurePrice(value == null ? defaultValue : value);
        return this;
    }

    public String getCustomerId() {
        return customerId;
    }

    public void setCustomerId(String value) {
        this.customerId = value;
    }

    public BandBean withCustomerId(String value) {
        setCustomerId(value);
        return this;
    }

    public BandBean withCustomerId(String value, String defaultValue) {
        setCustomerId(value == null ? defaultValue : value);
        return this;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String value) {
        this.phone = value;
    }

    public BandBean withPhone(String value) {
        setPhone(value);
        return this;
    }

    public BandBean withPhone(String value, String defaultValue) {
        setPhone(value == null ? defaultValue : value);
        return this;
    }

    public Object getValueOf(String name) {
        switch (name) {
            case "shopId":
                return getShopId();
            case "number":
                return getNumber();
            case "time":
                return getTime();
            case "deskNumber":
                return getDeskNumber();
            case "totalPrice":
                return getTotalPrice();
            case "finalPrice":
                return getFinalPrice();
            case "ensurePrice":
                return getEnsurePrice();
            case "customerId":
                return getCustomerId();
            case "phone":
                return getPhone();
        }
        return null;
    }

    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }

    @Override
    public int hashCode() {
        return signature().hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof BandBean)) return false;
        return signature().equals(((BandBean) o).signature());
    }

    public String signature() {
        throw new RuntimeException("Bean BandBean has no signature defined, no hash code or equals possible.");
    }
}
